package airplane.obj;

import airplane.utils.GameUtils;
import airplane.war.GameWin;

import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;

public class PlaneObj extends GameObj {

    public PlaneObj(Image imag, int x, int y, int width, int height, int speed, GameWin gameWin) {
        super(imag, x, y, width, height, speed, gameWin);
    }

    @Override
    public void paintSelf(Graphics graphics) {
        super.paintSelf(graphics);
        // 监听鼠标
        this.gameWin.addMouseMotionListener(new MouseAdapter() {
            @Override
            public void mouseMoved(MouseEvent e) {
                super.mouseMoved(e);
                //飞机坐标为鼠标坐标
                x = e.getX() - 11;
                y = e.getY() - 16;
            }
        });

        for (BoosShellObj boosShellObj : GameUtils.boosShellObjList) {
            if (this.getRec().intersects(boosShellObj.getRec())) {
                GameWin.state = 3;
                gameWin.repaint = 0;
            }
        }
    }
}
